/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Principal.java
 *
 * Created on 12/10/2010, 12:51:45 AM
 */

package pe.edu.upla.lamerced.desk.view;

import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
import net.sf.jasperreports.engine.JRParameter;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.util.SimpleFileResolver;
import net.sf.jasperreports.view.JasperViewer;
import pe.edu.upla.lamerced.Inicial;
import pe.edu.upla.lamerced.bean.Users;
import pe.edu.upla.lamerced.desk.view.clientes.ClientesLista;
import pe.edu.upla.lamerced.desk.view.clientes.UsuariosLista;
import pe.edu.upla.lamerced.desk.view.hospedaje.HospedajeLista;
import pe.edu.upla.lamerced.desk.view.hospedaje.HospedajeNuevo;
import pe.edu.upla.lamerced.desk.view.hospedaje.ReservaLista;
import pe.edu.upla.lamerced.desk.view.hospedaje.ServicioVender;
import pe.edu.upla.lamerced.desk.view.maestro.FormServicios;
import pe.edu.upla.lamerced.desk.view.maestro.ListaCategoria;
import pe.edu.upla.lamerced.desk.view.maestro.ListaDetalleCategoria;
import pe.edu.upla.lamerced.desk.view.maestro.ListaHabitaciones;
import pe.edu.upla.lamerced.desk.view.maestro.ListaServicios;
import pe.edu.upla.lamerced.desk.view.maestro.ListaTipoHabitacion;

/**
 *
 * @author elvis
 */
public class Principal extends javax.swing.JFrame {

   //private ClientesLista clientesLista;
   
    /** Creates new form Principal */
    public Principal() {
        initComponents();
        //clientesLista = Inicial.getFactory().getBean("");
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar2 = new javax.swing.JMenuBar();
        jMenu6 = new javax.swing.JMenu();
        jMenu7 = new javax.swing.JMenu();
        jDesktopPane1 = new javax.swing.JDesktopPane();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        opcListaClientes = new javax.swing.JMenuItem();
        opcListaUsuarios = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        opcReservar = new javax.swing.JMenuItem();
        opcLHospedajes = new javax.swing.JMenuItem();
        opcNHospedaje = new javax.swing.JMenuItem();
        opcVenderServicio = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        opcRepIngHospe = new javax.swing.JMenuItem();
        opcRepIngServ = new javax.swing.JMenuItem();
        opcRepOcHotl = new javax.swing.JMenuItem();
        opcRepHosPrevReser = new javax.swing.JMenuItem();
        opcJospDirecto = new javax.swing.JMenuItem();
        jMenu5 = new javax.swing.JMenu();
        opcMsTipoHab = new javax.swing.JMenuItem();
        opMsHabit = new javax.swing.JMenuItem();
        opcMsCat = new javax.swing.JMenuItem();
        opcMsEquip = new javax.swing.JMenuItem();
        opcMsServ = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();

        jMenu6.setText("File");
        jMenuBar2.add(jMenu6);

        jMenu7.setText("Edit");
        jMenuBar2.add(jMenu7);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("SISTEMA HOTELERO");

        jDesktopPane1.setBackground(new java.awt.Color(204, 204, 255));
        jDesktopPane1.setToolTipText("SISTEMA HOTELERO");

        jMenu1.setText("Usuarios");

        opcListaClientes.setText("Lista de Clientes");
        opcListaClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcListaClientesActionPerformed(evt);
            }
        });
        jMenu1.add(opcListaClientes);

        opcListaUsuarios.setText("Lista de Usuarios");
        opcListaUsuarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcListaUsuariosActionPerformed(evt);
            }
        });
        jMenu1.add(opcListaUsuarios);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Hospedaje");
        jMenu2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu2ActionPerformed(evt);
            }
        });

        opcReservar.setText("Reservar");
        opcReservar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcReservarActionPerformed(evt);
            }
        });
        jMenu2.add(opcReservar);

        opcLHospedajes.setText("Hospedaje");
        opcLHospedajes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcLHospedajesActionPerformed(evt);
            }
        });
        jMenu2.add(opcLHospedajes);

        opcNHospedaje.setText("Nuevo hospedaje");
        opcNHospedaje.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcNHospedajeActionPerformed(evt);
            }
        });
        jMenu2.add(opcNHospedaje);

        opcVenderServicio.setText("Vender servicio");
        opcVenderServicio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcVenderServicioActionPerformed(evt);
            }
        });
        jMenu2.add(opcVenderServicio);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Reportes");

        opcRepIngHospe.setText("Ingresos por Hospedaje");
        opcRepIngHospe.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcRepIngHospeActionPerformed(evt);
            }
        });
        jMenu3.add(opcRepIngHospe);

        opcRepIngServ.setText("Ingresos por servicios");
        opcRepIngServ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcRepIngServActionPerformed(evt);
            }
        });
        jMenu3.add(opcRepIngServ);

        opcRepOcHotl.setText("Ocupacion del Hotel");
        opcRepOcHotl.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcRepOcHotlActionPerformed(evt);
            }
        });
        jMenu3.add(opcRepOcHotl);

        opcRepHosPrevReser.setText("Hospedajes previa Cita");
        opcRepHosPrevReser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcRepHosPrevReserActionPerformed(evt);
            }
        });
        jMenu3.add(opcRepHosPrevReser);

        opcJospDirecto.setText("Hospedajes Directos");
        opcJospDirecto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcJospDirectoActionPerformed(evt);
            }
        });
        jMenu3.add(opcJospDirecto);

        jMenuBar1.add(jMenu3);

        jMenu5.setText("Maestros");

        opcMsTipoHab.setText("Tipo de Habitacion");
        opcMsTipoHab.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcMsTipoHabActionPerformed(evt);
            }
        });
        jMenu5.add(opcMsTipoHab);

        opMsHabit.setText("Habitaciones");
        opMsHabit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opMsHabitActionPerformed(evt);
            }
        });
        jMenu5.add(opMsHabit);

        opcMsCat.setText("Categoria de habitacion");
        opcMsCat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcMsCatActionPerformed(evt);
            }
        });
        jMenu5.add(opcMsCat);

        opcMsEquip.setText("Equipamiento Categoria");
        opcMsEquip.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcMsEquipActionPerformed(evt);
            }
        });
        jMenu5.add(opcMsEquip);

        opcMsServ.setText("Servicio");
        opcMsServ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                opcMsServActionPerformed(evt);
            }
        });
        jMenu5.add(opcMsServ);

        jMenuBar1.add(jMenu5);

        jMenu4.setText("Ayuda");

        jMenuItem7.setText("Cambiar clave");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem7);

        jMenuItem4.setText("Acerca del sistema");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem4);

        jMenuBar1.add(jMenu4);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 697, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 477, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void opcListaClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcListaClientesActionPerformed
       ClientesLista clientesLista = new ClientesLista();
       clientesLista.setEscritorio(this.jDesktopPane1);
       this.jDesktopPane1.add(clientesLista);
       clientesLista.cargaInicial();
       clientesLista.setVisible(true);
    }//GEN-LAST:event_opcListaClientesActionPerformed

    private void opcRepIngHospeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcRepIngHospeActionPerformed
       // INGRESOS POR HOSPEDAJE
      try{
         File carpeta = new File("resources");
         String ruta = carpeta.getAbsolutePath();
         File f = new File(ruta+"/repIngresosHospedaje.jasper");
         Map parameters = new HashMap();
         parameters.put(JRParameter.REPORT_FILE_RESOLVER, new SimpleFileResolver(carpeta));
         DataSource dataSource = (DataSource)Inicial.getFactory().getBean("dataSource");
         JasperPrint jasperPrint = JasperFillManager.fillReport( new FileInputStream(f) ,parameters,dataSource.getConnection());
         JasperViewer jviewer = new JasperViewer(jasperPrint,false);
         jviewer.show();
       }
       catch (Exception j){
           j.printStackTrace();
       }
    }//GEN-LAST:event_opcRepIngHospeActionPerformed

    private void opcRepIngServActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcRepIngServActionPerformed
       // INGRESOS POR SERVICIOS
       try{
         File carpeta = new File("resources");
         String ruta = carpeta.getAbsolutePath();
         File f = new File(ruta+"/repIngServicios.jasper");
         Map parameters = new HashMap();
         parameters.put(JRParameter.REPORT_FILE_RESOLVER, new SimpleFileResolver(carpeta));
         DataSource dataSource = (DataSource)Inicial.getFactory().getBean("dataSource");
         JasperPrint jasperPrint = JasperFillManager.fillReport( new FileInputStream(f) ,parameters,dataSource.getConnection());
         JasperViewer jviewer = new JasperViewer(jasperPrint,false);
         jviewer.show();
       }
       catch (Exception j){
           j.printStackTrace();
       }
    }//GEN-LAST:event_opcRepIngServActionPerformed

    private void opcRepOcHotlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcRepOcHotlActionPerformed
       // OCUPACION DEL HOTEL
       try{
         File carpeta = new File("resources");
         String ruta = carpeta.getAbsolutePath();
         File f = new File(ruta+"/repOcupacionHotel.jasper");
         Map parameters = new HashMap();
         parameters.put(JRParameter.REPORT_FILE_RESOLVER, new SimpleFileResolver(carpeta));
         DataSource dataSource = (DataSource)Inicial.getFactory().getBean("dataSource");
         JasperPrint jasperPrint = JasperFillManager.fillReport( new FileInputStream(f) ,parameters,dataSource.getConnection());
         JasperViewer jviewer = new JasperViewer(jasperPrint,false);
         jviewer.show();
       }
       catch (Exception j){
           j.printStackTrace();
       }
    }//GEN-LAST:event_opcRepOcHotlActionPerformed

    private void opcReservarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcReservarActionPerformed
       // TODO registrar una nueva reserva
       ReservaLista rs = new ReservaLista();
       rs.setEscritorio(this.jDesktopPane1);
       rs.cargaInicial();
       rs.setVisible(true);
       this.jDesktopPane1.add(rs);
    }//GEN-LAST:event_opcReservarActionPerformed

    private void opcLHospedajesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcLHospedajesActionPerformed
       // TODO hospedaje
       HospedajeLista hn = new HospedajeLista();
       this.jDesktopPane1.add(hn);
       hn.setEscritorio(this.jDesktopPane1);
       hn.preLoadFormHospLst();
       hn.setVisible(true);
    }//GEN-LAST:event_opcLHospedajesActionPerformed

    private void opcVenderServicioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcVenderServicioActionPerformed
       // TODO vender servicio
       ServicioVender sv = new ServicioVender();
       sv.setEscritorio(jDesktopPane1);
       sv.setVisible(true);
       sv.cargaInicial();
       this.jDesktopPane1.add(sv);
    }//GEN-LAST:event_opcVenderServicioActionPerformed

    private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu2ActionPerformed
       // TODO add your handling code here:
    }//GEN-LAST:event_jMenu2ActionPerformed

    private void opcListaUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcListaUsuariosActionPerformed
       // TODO add your handling code here:
       //lista de usuarios
       UsuariosLista form = new UsuariosLista();
       form.setEscritorio(jDesktopPane1);
       jDesktopPane1.add(form);
       form.cargaInicial();
       form.setVisible(true);
    }//GEN-LAST:event_opcListaUsuariosActionPerformed

    private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
       UsuarioClave form = new UsuarioClave();
       this.jDesktopPane1.add(form);
       form.setUsuario(Login.getUserLogin());
       form.cargaInicial();
       form.setVisible(true);
    }//GEN-LAST:event_jMenuItem7ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
       AcercaDe form = new AcercaDe();
       jDesktopPane1.add(form);
       form.setVisible(true);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void opcNHospedajeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcNHospedajeActionPerformed
       // competamente nuevo hospedaje sin previa reserva
       HospedajeNuevo form = new HospedajeNuevo();
       form.setEscritorio(jDesktopPane1);
       form.cargaInicial();
       form.setVisible(true);
       jDesktopPane1.add(form);
    }//GEN-LAST:event_opcNHospedajeActionPerformed

    private void opMsHabitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opMsHabitActionPerformed
       // TODO add your handling code here:
       ListaHabitaciones form = new ListaHabitaciones();
       form.setEscitorio(jDesktopPane1);
       jDesktopPane1.add(form);
       form.cargaInicial();
       form.setVisible(true);
    }//GEN-LAST:event_opMsHabitActionPerformed

    private void opcRepHosPrevReserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcRepHosPrevReserActionPerformed
       // HOSPEDAJE PREVIA CITA
       try{
         File carpeta = new File("resources");
         String ruta = carpeta.getAbsolutePath();
         File f = new File(ruta+"/repHospPorReserva.jasper");
         Map parameters = new HashMap();
         parameters.put(JRParameter.REPORT_FILE_RESOLVER, new SimpleFileResolver(carpeta));
         DataSource dataSource = (DataSource)Inicial.getFactory().getBean("dataSource");
         JasperPrint jasperPrint = JasperFillManager.fillReport( new FileInputStream(f) ,parameters,dataSource.getConnection());
         JasperViewer jviewer = new JasperViewer(jasperPrint,false);
         jviewer.show();
       }
       catch (Exception j){
           j.printStackTrace();
       }
    }//GEN-LAST:event_opcRepHosPrevReserActionPerformed

    private void opcJospDirectoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcJospDirectoActionPerformed
       // HSPEDAJES DIRECTOS
       try{
         File carpeta = new File("resources");
         String ruta = carpeta.getAbsolutePath();
         File f = new File(ruta+"/repHospPorHospedaje.jasper");
         Map parameters = new HashMap();
         parameters.put(JRParameter.REPORT_FILE_RESOLVER, new SimpleFileResolver(carpeta));
         DataSource dataSource = (DataSource)Inicial.getFactory().getBean("dataSource");
         JasperPrint jasperPrint = JasperFillManager.fillReport( new FileInputStream(f) ,parameters,dataSource.getConnection());
         JasperViewer jviewer = new JasperViewer(jasperPrint,false);
         jviewer.show();
       }
       catch (Exception j){
           j.printStackTrace();
       }
    }//GEN-LAST:event_opcJospDirectoActionPerformed

    private void opcMsCatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcMsCatActionPerformed
       // TODO add your handling code here:
       ListaCategoria form = new ListaCategoria();
       jDesktopPane1.add(form);
       form.setEscritorio(jDesktopPane1);
       form.cargainicial();
       form.setVisible(true);
    }//GEN-LAST:event_opcMsCatActionPerformed

    private void opcMsServActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcMsServActionPerformed
       // TODO add your handling code here:
       ListaServicios form = new ListaServicios();
       jDesktopPane1.add(form);
       form.setEscritorio(jDesktopPane1);
       form.cargainicial();
       form.setVisible(true);
    }//GEN-LAST:event_opcMsServActionPerformed

    private void opcMsEquipActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcMsEquipActionPerformed
       ListaDetalleCategoria form = new ListaDetalleCategoria();
       form.setEscritorio(jDesktopPane1);
       jDesktopPane1.add(form);
       form.cargainicial();
       form.setVisible(true);
    }//GEN-LAST:event_opcMsEquipActionPerformed

    private void opcMsTipoHabActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opcMsTipoHabActionPerformed
       // tipo de habitacion
       ListaTipoHabitacion form = new ListaTipoHabitacion();
       form.setEscritorio(jDesktopPane1);
       form.cargaInicial();
       jDesktopPane1.add(form);
       form.setVisible(true);
    }//GEN-LAST:event_opcMsTipoHabActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Principal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenu jMenu6;
    private javax.swing.JMenu jMenu7;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuBar jMenuBar2;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem opMsHabit;
    private javax.swing.JMenuItem opcJospDirecto;
    private javax.swing.JMenuItem opcLHospedajes;
    private javax.swing.JMenuItem opcListaClientes;
    private javax.swing.JMenuItem opcListaUsuarios;
    private javax.swing.JMenuItem opcMsCat;
    private javax.swing.JMenuItem opcMsEquip;
    private javax.swing.JMenuItem opcMsServ;
    private javax.swing.JMenuItem opcMsTipoHab;
    private javax.swing.JMenuItem opcNHospedaje;
    private javax.swing.JMenuItem opcRepHosPrevReser;
    private javax.swing.JMenuItem opcRepIngHospe;
    private javax.swing.JMenuItem opcRepIngServ;
    private javax.swing.JMenuItem opcRepOcHotl;
    private javax.swing.JMenuItem opcReservar;
    private javax.swing.JMenuItem opcVenderServicio;
    // End of variables declaration//GEN-END:variables

}
